home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Exceptions vs. assertions
- Date: 8 Jan 1996 14:48:01 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4crar1$9oh@dawn.mmm.com>
- References: <4cbfac$kst@dawn.mmm.com> <DKMJsE.LH5@falcon.daytonoh.attgis.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Dick Menninger (Dick.Menninger@DaytonOH.ATTGIS.COM) wrote:
-
- > > ==========Kevin J Hopps, 1/2/96==========
- >
- > > Chris Page (page@tiac.net) wrote:
- > > > lalit@gramercy.ios.com (lalit gidwani) wrote:
-
- > [stuff deleted]
-
- > > > is this: If I expect a condition to occur during normal operation of
- > > > my program, then I do not use exceptions for it. I use exceptions,
- > > > only for exceptionally conditions, which I do not expect to
- > occur, but
- > > > I have to anticipate.
- > >
- > > This is a good approach. The issue of whether to throw exceptions or
- > > return status values is best decided by how likely the failure is than
- > > by how catastrophic it is. (Besides, the caller of a function knows
- > > better than the function itself how costly the failure is.)
-
- > Exceptions are a control paradigm. Would you choose any
- > other control paradigm based on frequency or importance
- > of the issue being modeled (programmed)? It would seem that
- > the choice should be based on trying for the best expression
- > of the problem.
-
- Making decisions this way would seem to make it easier to understand
- what the code is doing. This is an important consideration, but it
- is not the only consideration.
-
- > I suspect there are problems to be modeled
- > where they are best expressed with an exception used for
- > the success path. In fact, that is one of the reasons I push
- > for multiple simultaneous exceptions being valid in the language
- > (so you can have an error exception while returning a success
- > exception).
-
- I'm not sure what you mean by "multiple simultaneous exceptions."
-
- > Such problems are likely to be related to problems
- > where multi-level breaks (usually simulated by a goto) are very
- > helpful in clarifying the expression of the model. For such
- > problems, the solution may perform better with an exception
- > for success.
-
- Even if I thought that using a goto to simulate a multi-level break
- was very helpful in clarifying the expression of the model, I would
- probably avoid it if it both
- a) was likely to occur with significant frequency, and
- b) made the code 2-3 times slower.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-